package com.chia.multienty.workflow.config;

import com.chia.multienty.core.dubbo.service.DubboWechatService;
import com.chia.multienty.core.dubbo.service.DubboWorkflowService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.spring.ReferenceBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty(prefix = "dubbo", name = "enabled", havingValue = "true")
public class DubboReferenceConfiguration {


    @Bean
    @DubboReference(timeout = 5000)
    public ReferenceBean<DubboWechatService> dubboWechatServiceReferenceBean() {
        return new ReferenceBean<>();
    }

    @Bean
    public DubboWechatService dubboWechatService(ReferenceBean<DubboWechatService> dubboWechatServiceReferenceBean) {
        DubboWechatService dubboWechatService = dubboWechatServiceReferenceBean.getObject();
        return dubboWechatService;
    }
    @Bean
    @DubboReference(timeout = 5000)
    public ReferenceBean<DubboWorkflowService> dubboWorkflowServiceReferenceBean() {
        return new ReferenceBean<>();
    }

    @Bean
    public DubboWorkflowService dubboWorkflowService(ReferenceBean<DubboWorkflowService> dubboWorkflowServiceReferenceBean) {
        DubboWorkflowService dubboWorkflowService = dubboWorkflowServiceReferenceBean.getObject();
        return dubboWorkflowService;
    }
}
